# Maintainer: taotieren <admin@taotieren.com>

pkgname=linglong-pica
_tagname=1.2.4-1
pkgver="${_tagname//-/_}"
# pkgver=1.2.4
pkgrel=2
pkgdesc='deb package to Linglong package tool.'
arch=($CARCH)
url='https://github.com/linuxdeepin/linglong-pica'
license=('LGPL-3.0-or-later')
provides=(
  ${pkgname}
)
conflicts=(
  ${pkgname}
)
replaces=()
depends=(
  sh
  linyaps
)
makedepends=(
  git
  go
  pkgconf
)
# checkdepends=(
#   apt
# )
optdepends=()
source=("${pkgname}::git+${url}.git#tag=${_tagname}")
sha256sums=('7440c177ab608542fd0f079f9994c2f6230d5f82')

prepare() {
  git -C "${srcdir}/${pkgname}" clean -dfx
}

build() {
  cd "${srcdir}"/${pkgname}/
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"

  export GO111MODULE=on
  export GOPROXY=https://goproxy.cn,direct
 
  sed -i 's|${PREFIX}/libexec|${PREFIX}/lib|g' Makefile
  make build
}

# check() {
#   cd "${srcdir}"/${pkgname}/
#   make test
# }

package() {
  cd "${srcdir}"/${pkgname}
  make DESTDIR="${pkgdir}" install
  install -Dm644 "LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}
